<%@page import="com.framework.entity.Global"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="com.biz.utils.ConfigUtil" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
    String resoursUrl = ConfigUtil.get("RESOURCES_URL");
    String picUrl=ConfigUtil.get("OSSURL");
%>

<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="UTF-8">
<title>活动详情</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<jsp:include page="/jsp/inc.jsp"></jsp:include>
<style>
	.orgaspan{
		top: -0.03rem;
		position: relative;
		height: inherit;
		line-height: inherit;
		padding:.01rem .16rem;
	}
	.toactback{
		border-top: 1px solid #e8e8e8;
		background: url(<%=basePath%>resources/image/bg_actback.png) no-repeat center center/100% 100%;
		padding: .4rem 0;
		text-align: center;
	}
	.actbacktxt{
		display: inline-block;
		padding-right:.4rem ;
		background-image: url(<%=basePath%>resources/image/arrow-right-blue.png);
		background-repeat: no-repeat;
		background-position: right center;
		background-size:.14rem .21rem ;
		color:#00a0e9;
		font-size: .32rem;
		font-weight: bold;
	}
</style>
</head>
<body style="padding-bottom: 1.1rem;">
<div class="activelist">
	<div class="activesign">
		<p class="actpositopimg">
			<img src="<%=picUrl%>/${map.path}" alt="" class="">
			<c:if test="${map.state=='3'}">
			<span class="actover">活动已结束</span>
			</c:if>
		</p>
		<div class="actsign">
			<span class="txt">${map.subject}</span>
			<span class="point"><span class="num">${map.integral}</span>积分</span>
			<br class="clear"/>
		</div>
		<div class="avtivetimenum">
			<div class="time">时间：${map.activityTime}</div>
			<div class="num">所需人数：${map.successCount}/${map.limitCount}</div>
			<br class="clear"/>
		</div>
	</div>
	<div class="actinfo">
		${map.activityNotes}
	</div>
</div>
<div class="activeorg">
	<img src="<%=picUrl%>/${map.coverId}" alt="" class="activeorgimg">
	<div class="orgaxinxi">
		<div class="faqiorgname">${map.groupName}<span class="orgaspan">组织</span></div>
		<div class="faqiname">活动发起人：${map.personName}</div>
		<div class="orgatel">联系方式：${map.phone}</div>
		<div class="orgaadr">地址：${map.activityAdd}</div>
	</div>
</div>
<c:if test="${map.state=='3'}">
	<div class="toactback" onclick="toReveiw('${map.id}');">
		<span class="actbacktxt">活动回顾</span>
	</div>
</c:if>
<c:if test="${map.state=='3'}">
<div class="commentcover">
	<div class="plNum">评论（<span class="num">${map.commentCount}</span>条）</div>
	<div class="comments">
		<c:forEach items="${commentList}" var="obj" varStatus="vs">
		<div class="comlist">
			<img src="${obj.cover}" alt="" class="plTX">
			<div class="plright">
				<div class="rightline1">
					<div class="fl-l name">${obj.personName}</div>
					<div class="fl-r time">${obj.appraiseTime}</div>
					<br class="clear"/>
				</div>
				<div class="rightline2">
						${obj.comment}
				</div>
			</div>
		</div>
		</c:forEach>
	</div>
</div>
</c:if>

<div class="fixedbtmbtn">
	<c:if test="${map.state=='1'}">
	<button id="app1" type="button" class="btmbtn-blue" style="background-color: #00a0e9" onclick="doApply('${map.id}','0')">我要报名</button>
	<button id="app2" type="button" class="btmbtn-blue" style="background-color: #d0d0d0" onclick="doApply('${map.id}','1')">取消报名</button>
		</c:if>
<c:if test="${map.state=='3'}">
	<button type="button" class="btmbtn-blue"  onclick="toCommentList('${map.id}')" >留言评论</button>
</c:if>
</div>
<span class="scantip baomingok"><span class="tipok">报名成功，等待审核</span></span>

<script src="<%=basePath%>resources/js/ydui.js"></script>
<script type="text/javascript">
	$(function(){
	    var count='${count}';
	    if(count=='0'){
            $("#app1").show();
            $("#app2").hide();
        }else{
            $("#app1").hide();
            $("#app2").show();
        }
	})

	function doApply(id,state) {
		if(state=='0'){
            //报名
            checkPhone(id,state,'0');
           // toCommentRecord(id,state);
		}else{
            window.YDUI.dialog.confirm('是否取消报名', '如重新报名，还需等待审核', function () {
                checkPhone(id,state,'0');
              //  toCommentRecord(id,state);
            });
		}
    }

function toCommentRecord(id,state) {
    var url = "${pageContext.request.contextPath}/mebactivity/toCommentRecord.ac?id="+id+"&state="+state;
    $.ajax({
        type: "post",
        url: url,
        dataType: 'json',
        success: function(data) {
            if(data=="操作成功"){
            if(state=="0"){
					$("#app1").hide();
					$("#app2").show();
                $(".baomingok").show().delay(1000).hide(500);
			}else{
                $("#app1").show();
                $("#app2").hide();
            }
        }else{
                window.YDUI.dialog.alert(data);
            }
        }
    });
}

function  toCommentList(id) {
    checkPhone(id,'','1');
   // window.location.href='${pageContext.request.contextPath}/mebactivity/toCommentList.ac?id='+id;
}

//报名活动 先检查改用户是否已经填写手机号
	function checkPhone(id,state,type){
        var url = "${pageContext.request.contextPath}/mebactivity/checkPhone.ac";
        $.ajax({
            type: "post",
            url: url,
            dataType: 'json',
            success: function(data) {
				if(data=="1"){
                    window.location.href='${pageContext.request.contextPath}/mebactivity/updateInfo.ac?id='+id;
				}else{
				    if(type=="0"){
                        toCommentRecord(id,state);
                    }else{
                        window.location.href='${pageContext.request.contextPath}/mebactivity/toCommentList.ac?id='+id;
                    }

				}

            }
        });
	}

	function toReveiw(id)
	{
        window.location.href='${pageContext.request.contextPath}/mebactivity/toReveiw.ac?id='+id;
	}
</script>

</body>
</html>
